package com.baicaixiaozhan.springsecurityswaggerdemo.service.impl;

import com.baicaixiaozhan.springsecurityswaggerdemo.pojo.Person;
import com.baicaixiaozhan.springsecurityswaggerdemo.service.CustomService;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DESC:
 *
 * @author : baicaixiaozhan
 * @since : 2020-11-04
 */
@Service("customServiceImpl")
public class CustomServiceImpl implements CustomService {

    private static final List<Person> PERSON = Lists.newArrayList(
            Person.builder().name("张三").address("深圳").build(),
            Person.builder().name("李四").address("长沙").build(),
            Person.builder().name("王五").address("湘潭").build()
    );

    @Override
    public List<Person> getPersonList() {
        return PERSON;
    }

    @Override
    public Person getPersonByName(String name) {
        return PERSON.stream()
                .filter(person -> name.equals(person.getName()))
                .findFirst().orElse(new Person());
    }

}
